By: Fischer Heimburger (@fheimburger97)

Introduction

The Mission District (known as “This Mission”) in San Francisco known for it’s widening economic inequity, relatively high ethnic diversity–including being a local hub for Latinx culture and heritage, and vibrant food scene. This research seeks to first cultivate an understanding of the socio-economic landscape of the Mission District, and then initiate research on how this landscape is reflected in the distribution of food retailers.

Economic inequity is a major challenge facing the Mission District today. In 2020, it was found that “the highest and lowest income brackets compose almost 40% of all Mission households” (Mission Action Plan 2020. This demonstrates the increasing income gap experienced in the Mission District. In addition, the economic landscape of the Mission District is highly influenced by gentrification–the process by which the migration of high-income residents to a place displaces low-income, often marginalized, residents (Chapple and Thomas 2021). San Francisco was recently found to be the most intensely gentrified city in America (Richardson, Mitchell, and Edlebi 2020) and the Mission District, one of the neighborhoods with the most advanced levels of gentrification (Chapple and Thomas 2021). We hope to understand this unique and stark economic landscape by mapping out median household incomes by census tract within the Mission District. Our research on this is influenced by data and figures from the Urban Displacement Project. The Urban Displacement Project traces gentrification throughout the San Francisco Bay Area. As a part of their studies, they gather data on median income levels within the Mission District and map out their findings. We hope, in part, to recreate aspects of their figures with updated census data.

While much of the Bay Area is growing more racially segregated (Menendian, Gambhir and Gailes 2021), The Mission is unique for its relatively high ethnic diversity (Hom 2021). While overall in 2019 the Mission District was 38.7% Latinx, 36.4% White, and 13.7% Asian (City Data 2021); the demographic makeup of race varies depending on locale (Hom 2021). Additionally, recent years have shown dynamic shifts in demographics as the 2020 Census revealed a 14.4% decline in Latinx residents within the Mission District and a 34.8% increase in Asian residents (Horowitz and Jarret 2021). The Othering & Belonging Institute researches levels of segregation in the San Francisco Bay Area. As part of their research, they have created maps of the Mission District that display levels of segregation and racial diversity. We seek to create similar maps that display racial majorities by census tract to further understand the demographic landscape of The Mission. We then hope to understand how these socio-economic landscapes interact the landscape of food retailers in the Mission District.

Food systems are complex, interconnected bio-physical and socio-economic webs that are influenced by environmental, social, political, and economic systems, institutions, and actors (Ericksen 2008). For many living in cities, like those within the Mission District, relationships with food systems revolve around food retailers—including supermarkets, grocery stores, corner markets, and convenience stores—that help connect food producers with food consumers (Trivette 2019). Using data from the City of San Francisco, we hope to map out the current distribution of food retailers in the Mission District. Then we seek to understand how this distribution may be interconnected with class and race.

Our research is organized as follows. First, we map out income levels by census tract in the Mission District. Second, we map out racial majorities by census tract in The Mission. We then create a demographic table that organizes the socio-economic landscape of the district. In the fourth section we map out the distribution of food retailers within the Mission District. Lastly, we overlay the socio-economic maps with the food retailer map.

Data note: We used the following libraries to analyze our data. Additionally, please run install.packages("tidycensus") in the console window.

Google API Key – need to upload key #{r} register_google(key = "", write = TRUE) #

retail_data <- read_csv("Food Retail Final List (Edit 3_30).csv") %>%
  select(!"Timestamp")
## New names:
## * `` -> ...48
## Rows: 97 Columns: 51
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (35): Timestamp, Name of Food Retailer, Address, Date Assessed, Type of ...
## dbl (14): Median Price of a Dozen Eggs, Median Price of a Loaf of Bread, Mil...
## lgl  (1): ...48
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
retail_data$coord <- paste(retail_data$lon, retail_data$lat) 
retail_data

I Tract Income Typology

Table 1.1: Downloading San Francisco’s Geopackage

First, we downloaded the geopackage for San Francisco. In the following chunk, we load the geopackage using read_sf and filter for census tracts in the Mission District. We select to show “GEOID” and “geom” which will help create our map.

gfile <- read_sf("sanfrancisco.gpkg") %>%
  select(GEOID, geom) %>%
  filter(GEOID == "6075020200" | GEOID == "6075020100" | GEOID == "6075020800" | GEOID == "6075020700" | GEOID == "6075022902" | GEOID == "6075020900" | GEOID == "6075017700" | GEOID == "6075022901" | GEOID == "6075022803" | GEOID == "6075022903" | GEOID == "6075022801" | GEOID == "6075021000" | GEOID == "6075022802")

Table 1.2: Downloading San Francisco’s Demographics

We then use read.csv to load typology data from the Urban Displacement Project github. The definitions for variable names can be found here.

demographics <- read.csv("https://raw.githubusercontent.com/urban-displacement/displacement-typologies/main/data/outputs/typologies/SanFrancisco_typology_output.csv")

Table 1.3: Median Household Income Table

First, we create the medianincome table which shows “GEOID” and “hinc_18”; “hinc_18” is the median household income in the past 12 months (in 2018 inflation-adjusted dollars) in 2018. Second, with left_join, we join the newly created medianincome table and the initial gfile table to create our incomejoin table.

medianincome <- demographics %>%
  select(GEOID, hinc_18) %>%
  rename("Income in Dollars" = hinc_18)
incomejoin <-left_join(gfile, medianincome, by = "GEOID")
incomejoin
medianincome_test <- demographics %>%
  select(GEOID, hinc_18) %>%
  mutate(median_income = case_when(
    hinc_18 <= 75000 ~ "40,000 - 75,000",
    hinc_18 >= 75001 & hinc_18 <= 110000 ~ "75,001 - 110,000",
    hinc_18 >= 110001 & hinc_18 <= 145000 ~ "110,001 - 145,000",
    hinc_18 >= 145001 ~ "145,001 - 180,000")) %>%
  rename("Income in Dollars" = hinc_18)
  #rename("Median Income" = median_income)
incomejoin_test <-left_join(gfile, medianincome_test, by = "GEOID")
incomejoin_test

Figure 1.1: Mapping Median Household Income in the Mission District

Using tmap and our incomejoin table, we then create a map showing median household income across census tracts in the Mission District.

incomemap_2 <- tm_shape(incomejoin_test) +
             tm_style("watercolor") +
             tm_polygons("median_income") +
             tm_layout(main.title="Median Household Income",
                       main.title.position = "centre",
                       main.title.size = 1.6) +
             tm_legend(position = c("right", "top"),
             legend.outside = TRUE,
             legend.outside.size = .35,
             legend.title.size = 1.5,
             legend.text.size = 1.2) +
  tm_compass(position = c("left", "top"))
incomemap_2

II Tract Racial Typology

To work with census data, we install tidycensus from CRAN with the following command: install.packages("tidycensus"). After loading the tidycensus and tidyverse libraries, obtain a Census API key. Note: 2020 decennial Census data use differential privacy, a technique that introduces errors into data to preserve respondent confidentiality, small counts should be interpreted with caution.

census_api_key("77bb8e57772d9321db5adcd03b9bf2c3bce563c3", install = TRUE, overwrite = TRUE)
## [1] "77bb8e57772d9321db5adcd03b9bf2c3bce563c3"

Table 2.1 Population Numbers by Race

Using tidycensus, we will get the values for four variables: total population, White population, Asian population, and Hispanic or Latino population. The argument to the geography parameter is “tract”, and by by specifying state, county, and year we get the desired population numbers for each census tract in San Francisco from 2020. Note that geometry is set to true in the first table to help create maps later.

#White Population
white <- get_decennial(geography = "tract",
                      state = "CA",
                      county = "San Francisco",
                      year = 2020,
                      variables = c(white = "P1_003N"))
#Asian Population
asian <- get_decennial(geography = "tract",
                      state = "CA",
                      county = "San Francisco",
                      year = 2020,
                      variables = c(asian = "P1_006N"))
#Hispanic or Latino Population
latinx <- get_decennial(geography = "tract",
                      state = "CA",
                      county = "San Francisco",
                      year = 2020,
                      variables = c(latinx = "P2_002N"))
#Total Population
totalpop <- get_decennial(geography = "tract",
                      state = "CA",
                      county = "San Francisco",
                      year = 2020,
                      variables = c(totalpop = "P1_002N"),
                      geometry = TRUE)
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |                                                                      |   1%
  |                                                                            
  |=                                                                     |   1%
  |                                                                            
  |=                                                                     |   2%
  |                                                                            
  |==                                                                    |   2%
  |                                                                            
  |==                                                                    |   3%
  |                                                                            
  |===                                                                   |   4%
  |                                                                            
  |===                                                                   |   5%
  |                                                                            
  |====                                                                  |   5%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |=====                                                                 |   7%
  |                                                                            
  |=====                                                                 |   8%
  |                                                                            
  |======                                                                |   8%
  |                                                                            
  |======                                                                |   9%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |========                                                              |  11%
  |                                                                            
  |========                                                              |  12%
  |                                                                            
  |=========                                                             |  13%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |===========                                                           |  15%
  |                                                                            
  |===========                                                           |  16%
  |                                                                            
  |============                                                          |  17%
  |                                                                            
  |============                                                          |  18%
  |                                                                            
  |=============                                                         |  19%
  |                                                                            
  |==============                                                        |  19%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |===============                                                       |  21%
  |                                                                            
  |================                                                      |  23%
  |                                                                            
  |==================                                                    |  26%
  |                                                                            
  |====================                                                  |  29%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |======================                                                |  31%
  |                                                                            
  |=======================                                               |  32%
  |                                                                            
  |========================                                              |  34%
  |                                                                            
  |=========================                                             |  35%
  |                                                                            
  |==========================                                            |  38%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |=============================                                         |  41%
  |                                                                            
  |==============================                                        |  43%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |======================================================================| 100%

Table 2.2: Race Percents

Next, with a series of left_join, we join the four previous tables by “GEOID”. We rename and select several important variables for neatness and clarity. We use mutate to add three columns displaying the percentage of the total population that each race is.

totalandwhite <- left_join(totalpop, white, by = "GEOID") %>%
    rename(tract = NAME.x,
           totalvar = variable.x,
           totalval = value.x,
           whitevar = variable.y,
           whiteval = value.y) %>%
  select(GEOID, tract, totalvar, totalval, whitevar, whiteval)
asianandlatinx <- left_join(asian, latinx, by = "GEOID") %>%
    rename(tract = NAME.x,
           asianvar = variable.x,
           asianval = value.x,
           latinxvar = variable.y,
           latinxval = value.y) %>%
  select(GEOID, asianvar, asianval, latinxvar, latinxval)
ethnic_table <- left_join(totalandwhite, asianandlatinx, by = "GEOID") %>%
  mutate(percwhite = (whiteval/totalval)*100) %>%
  mutate(percasian = (asianval/totalval)*100) %>%
  mutate(perclatinx = (latinxval/totalval)*100)
ethnic_table

Table 2.3: Race Percents and Majorities

Next, we mutate to add a “majority” column. In this column, we use case_when to show which of the three races has the highest percent of the population, and thus, is the majority of its tract.

percents <- ethnic_table  %>% 
  mutate(Majority = case_when(
    perclatinx > percasian & perclatinx > percwhite ~ "Hispanic or Latinx",
    percwhite > percasian & percwhite > perclatinx ~ "White",
    percasian > percwhite & percasian > perclatinx ~ "Asian")) %>%
  select(GEOID, tract, percwhite, percasian, perclatinx, Majority, geometry)

Table 2.4: Specifying the Boundaries

To narrow our scope, we then filter to only include census tracts in the Mission District of San Francisco.

mission_geo_zero <- percents %>% pull(GEOID)
mission_percents_clean <- percents %>%
  mutate(GEOID = substring(mission_geo_zero, 2)) %>%
  filter(GEOID == "6075020201" | GEOID == "6075020202" | GEOID == "6075020101" | GEOID == "6075020102" | GEOID == "6075020801" | GEOID == "6075020802" | GEOID == "6075020701" | GEOID == "6075020702" | GEOID == "6075022902" | GEOID == "6075020900" | GEOID == "6075017700" | GEOID == "6075022901" | GEOID == "6075022803" | GEOID == "6075022903" | GEOID == "6075022801" | GEOID == "6075021000" | GEOID == "6075022802")
mission_percents_clean

Figure 2.1: Mapping Racial Majorities in the Mission District

ethnic_map <-
  tm_shape(mission_percents_clean) +
  tm_polygons("Majority") +
  tm_style("watercolor") +
  tm_layout(main.title = "Racial Typography",
            main.title.position = "centre",
            main.title.size = 1.6) +
  tm_legend(position = c("right", "top"),
            legend.outside = TRUE,
            legend.outside.size = .35,
            legend.title.size = 1.5,
            legend.text.size = 1.2) +
  tm_compass(position = c("left", "top"))
ethnic_map

III Demographics Table

Table 3.1

incomejoin_chr <- incomejoin %>%
  mutate_at("GEOID", as.character)
incomejoin_chr

Table 3.2: Demographics Table

finaljoin <- right_join(st_drop_geometry(incomejoin_chr), st_drop_geometry(mission_percents_clean), by = "GEOID") %>% 
  select(GEOID, tract, "Income in Dollars", Majority, percwhite, perclatinx, percasian) %>% 
  rename("Median Income ($)" = "Income in Dollars", Tract = tract, "White Percentage" = percwhite, "Hispanic/Latinx Percentage" = perclatinx, "Asian Percentage" = percasian, "Racial Majority" = Majority)
finaljoin

IV Food Retailers

Table 4.1: Uploading business data from data.sfgov.org.

#SF_businesses <- read_csv("https://data.sfgov.org/api/views/g8m3-pdis/rows.csv?accessType=DOWNLOAD")
#SF_businesses

Table 4.2: Business in the Mission with LIC Code H in it. LIC codes with H’s are retail businesses, this was a crucial filtering step to finding food retailers.

#Mission_H_Codes <- SF_businesses %>%
   #filter(str_detect(`LIC Code`, "H"), `Neighborhoods - Analysis Boundaries` == "Mission") %>%
  #select(`Ownership Name`, `DBA Name`, `Street Address`, `Business Start Date`, `Business End Date`, `Mail State`, `NAICS Code`, `NAICS Code Description`, `LIC Code`, `LIC Code Description`, `Neighborhoods - Analysis Boundaries`)
#Mission_H_Codes %>% select(`Ownership Name`, `DBA Name`, `LIC Code`, `LIC Code Description`)

List 4.1: The following is a list of LIC codes that are food retailers. This list includes grocery stores, corner markets, convienence stores, supermarkets, bakeries, and drug stores. This list does not include restaurants.

#H_strings <- c("H01", "H02", "H03", "H04", "H05", "H06", "H07", "H08", "H09", "H10", "H11", "H12", "H13", "H14", "H16", "H19", "H80", "H81", "H83", "H88", "H89", "H92")

Table 4.3: The follow is a table that includes data on all food retailers within the Mission District.

#Final_Mission_Food_Retailers <- SF_businesses %>%
  #filter(`Neighborhoods - Analysis Boundaries` == "Mission") %>%
  #filter(str_detect(`LIC Code`, paste(H_strings, collapse = "|")))
#Final_Mission_Food_Retailers
#Clean_Final_Retail <- Final_Mission_Food_Retailers %>%
  #select("Ownership Name", "DBA Name", "Street Address", "LIC Code Description")
#Clean_Final_Retail
#Clean_Order_r <- Clean_Final_Retail[order(Clean_Final_Retail$"DBA Name"),]
#Clean_Order_r
#write.csv(Clean_Order_r, "C:\\Users\\fheim\\Desktop\\Test\\People.csv", row.names = FALSE)

List 4.2: The following are the coordinates for each food retail store in the Mission District.

#coordinates <- Final_Mission_Food_Retailers %>% pull("Business Location")
#coordinates

Figure 4.1: The follow is a map of all food retailers within the Mission District. Each dot represents a food retailer. While this map does not include streets or the outline of the Mission Distict, maps in the following section will include an outline of the Mission District along with demographic information.

#geo_final <- Final_Mission_Food_Retailers %>%
 # rename(geometry = `Business Location`) %>%
  #mutate(geometry = as.list(geometry)) %>%
#tm_shape(geo_final) + tm_dots()
retail_data <- read_csv("Food Retail Final List (Edit 3_30).csv")
## New names:
## * `` -> ...48
## Rows: 97 Columns: 51
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (35): Timestamp, Name of Food Retailer, Address, Date Assessed, Type of ...
## dbl (14): Median Price of a Dozen Eggs, Median Price of a Loaf of Bread, Mil...
## lgl  (1): ...48
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
retail_data$coord <- paste(retail_data$lon, retail_data$lat)
retail_data
retail_map <- retail_data %>%
 st_as_sf(coords = c('lon', 'lat'), crs = "WGS84")
tm_shape(retail_map) + tm_dots()

V Final Maps

Figure 5.1: Food Retailers and Median Household Income in the Mission District

dots <- tm_shape(retail_map) + tm_dots(size = .1, col="black") + tm_add_legend(shape = "tm_dots", labels = ('Food Retailers'), col = "black")
incomemap_with_food_retailers <- tm_shape(incomejoin_test) +
             tm_style("watercolor") +
             tm_polygons("median_income") +
             tm_layout(main.title="Median Household Income & Food Retailers",
                       main.title.position = "centre",
                       main.title.size = 1.6) +
             tm_legend(position = c("right", "top"),
             legend.outside = TRUE,
             legend.outside.size = .35,
             legend.title.size = 1.5,
             legend.text.size = 1.2) +
  tm_compass(position = c("left", "top"))
income_map_with_retail <- incomemap_with_food_retailers + dots
income_map_with_retail

Figure 5.2: Food Retailers and Racial Majorities in the Mission District

dots <- tm_shape(retail_map) + tm_dots(size = .1, col="black") + tm_add_legend(shape = "tm_dots", labels = ('Food Retailers'), col = "black")
ethnicity_map_with_food_retailers <-
  tm_shape(mission_percents_clean) +
  tm_polygons("Majority") +
  tm_style("watercolor") +
  tm_layout(main.title = "Racial Typography & Food Retailers",
            main.title.position = "centre",
            main.title.size = 1.6) +
  tm_legend(position = c("right", "top"),
            legend.outside = TRUE,
            legend.outside.size = .35,
            legend.title.size = 1.5,
            legend.text.size = 1.2) +
  tm_compass(position = c("left", "top"))
ethnicity_with_retail <- ethnicity_map_with_food_retailers + dots
ethnicity_with_retail

Conclusion

We were able to create maps of the Mission District based off median household income, racial majorities, and the distribution of food retailers. First, our map displaying median household income demonstrates the income gap experienced in the Mission today. Median income in tracts ranged from 40,000-60,000 USD on the lower end, to 160,000-180,000 USD on the upper end, with five other ranges in between. The lowest and highest median income tracts share a corner in the Northwestern quadrant of the Mission, demonstrating the proximity of the income gap in the Mission District.

Our racial typography map revealed that Hispanic or Latinx and White are the majority races in the Mission District. There are ten tracts that were predominantly white and seven tracts that are predominantly Hispanic or Latinx. These findings demonstrate that a degree of racial diversity exists in the Mission District, albeit largely between two races. If you compare the Median Household Income map with the Racial Typography map it is apparent that there is some degree of correlation between lower-income census tracts and tracts that are predominately Hispanic/Latinx. This may be an important trend when researching levels of gentrification within the Mission District. However, while our findings display that there is a degree of racial integration within the Mission District, they do not reveal the degree of segregation occurring within each tact. Further research would be needed to understand the landscape of segregation within each tract.

When we examined the socio-economic landscape of the Mission District in relation to the distribution of food retailers, we observed that there seems to be a level of correlation between the number of food retailers and tracts that are predominantly Hispanic and Latinx. If the maps we generated are compared to street maps (we direct readers to use Google Maps or other mapping software), the majority of food retailers are located along Mission Street and 24th Street–both streets are hubs for Latinx populations and culture. Our Racial Typography & Food Retailers map exemplifies that there may be a correlation between the location and quantity of food retailers in the Mission District and racial majority; however, our Median Household Income & Food Retailers map doesn’t demonstrate the same level of correlation. In the later case, the location of food retailers may have more to do with business corridors than median household income distribution.

In conclusion, we were able to replicate multiple maps used in researching the socio-economic landscapes of the Mission District. We were then able to start research, and open a discussion, about how this correlates with the distribution of food retailers within the district. Our work should be scene as a catalyst for future research on the food retail landscape of the Mission District. For example, it should be stated that in our maps all food retailers–regardless of size, stock, or purpose–are resembled by a single black dot. However, there is great diversity among food retailers. Some may be supermarkets, convenience stores, or corner markets. Additionally, some may cater to the general public, while others may sell specialty or ethnic foods. These kinds of differences would be important to know before drawing any conclusions regarding the distribution of food retailers in the Mission District in relation to socio-economic landscapes. Using our research as a launching pad, it is our hope that researches take our findings and code to further examine the role of food retailers in the socio-economic fabric of the Mission District.

#Research Data (DRAFT)

retail_data <- read_csv("Food Retail Final List (Edit 3_30).csv") %>%
  select(!"Timestamp")
## New names:
## * `` -> ...48
## Rows: 97 Columns: 51
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (35): Timestamp, Name of Food Retailer, Address, Date Assessed, Type of ...
## dbl (14): Median Price of a Dozen Eggs, Median Price of a Loaf of Bread, Mil...
## lgl  (1): ...48
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
retail_data$coord <- paste(retail_data$lon, retail_data$lat) 
retail_data
dots_ebt <- tm_shape(retail_map) + tm_dots(size=.1, col="EBT Accepted?", palette=c(No='red', Yes='black'))
incomemap_with_food_retailers <- tm_shape(incomejoin_test) +
             tm_style("watercolor") +
             tm_polygons("median_income") +
             tm_layout(main.title="Median Household Income & Food Retailers",
                       main.title.position = "centre",
                       main.title.size = 1.6) +
             tm_legend(position = c("right", "top"),
             legend.outside = TRUE,
             legend.outside.size = .35,
             legend.title.size = 1.5,
             legend.text.size = 1.2) +
  tm_compass(position = c("left", "top"))
income_plus_ebt <- incomemap_with_food_retailers + dots_ebt
income_plus_ebt

retail_EBT <- retail_map %>%
  filter(`EBT Accepted?` == "Yes")
retail_EBT
#income
just_geo <- incomejoin_test %>%
  select("geom")
just_mission_stores <- retail_map %>%
  filter(`Name of Food Retailer` != "Costco") %>%
  filter(`Name of Food Retailer` != "Whole Foods Market") %>%
  filter(`Address` != "2020 Market St, San Francisco, CA 94114")

intersection <- st_intersection(x = just_geo, y = just_mission_stores)
## Warning: attribute variables are assumed to be spatially constant throughout all
## geometries
intersection_join <- st_join(intersection, incomejoin_test, join = st_intersects)
intersection_join
plot(just_geo, graticule = st_crs(4326), key.pos = 1)
plot(intersection[1], col = "black", pch = 19, add = TRUE)

#ethnicity
just_geo_2 <- mission_percents_clean
just_geo_2 <- st_set_crs(just_geo_2, "WGS84")
## Warning: st_crs<- : replacing crs does not reproject data; use st_transform for
## that
intersection_2 <- st_intersection(x = just_mission_stores, y = just_geo_2)
## Warning: attribute variables are assumed to be spatially constant throughout all
## geometries
plot(just_geo_2$geometry, graticule = st_crs(4326), key.pos = 1)
## Warning in title(...): "key.pos" is not a graphical parameter
plot(intersection_2[1], col = "black", pch = 19, add = TRUE)

# Number of Retailers in each Median Income Group
int_result <- intersection_join %>% 
  group_by(median_income) %>% 
  count()

as.data.frame(int_result)

Results (lens of Agency)

contruct_tab <- intersection_2 %>%
  select(Majority, geometry)
primary_table <- st_join(intersection_join, contruct_tab)
primary_table

Access

Geography

maps

income_map_with_retail

ethnicity_with_retail

#### tables

costum_order <- c("40,000 - 75,000", "75,001 - 110,000", "110,001 - 145,000", "145,001 - 180,000")
income_count <- intersection_join %>% 
  group_by(median_income) %>% 
  count() %>%
  mutate(percent = (n / nrow(primary_table)) * 100) %>%
  rename("number of retailers" = "n") %>%
  slice(match(costum_order, median_income)) %>%
  st_drop_geometry()
income_count
ethnicity_count <- intersection_2 %>%
  group_by(Majority) %>%
  count() %>%
  mutate(percent = (n / nrow(primary_table)) * 100) %>%
  rename("number of retailers" = "n") %>%
  st_drop_geometry()
ethnicity_count

Price

price_table <- primary_table %>%
  mutate(egg_quartile = cut(primary_table$Median.Price.of.a.Dozen.Eggs, quantile(primary_table$Median.Price.of.a.Dozen.Eggs, na.rm = TRUE),include.lowest=TRUE,labels=FALSE)) %>%
  select(-Address, -Date.Assessed, -Type.of.Store, -What.type.of.Specialty.Food.Store., -EBT.Accepted., -Number.of.Locations..chain.., -Is.there.signage.in.other.languages.than.English., -If.so..what.languages., -Access.Notes, -Is.there.fresh.produce.available., -What.percentage.of.the.store.is.produce., -Is.there.organic.produce.available., -Is.there.local.produce.available., -How.many.types.of.fresh.produce.are.available., -Is.there.an.ethnic.section., -Are.there.options.besides.national.name.brand.ethnic.foods.,, -What.ethnic.food.nationalities.are.available., -Selection.Notes, -Is.there.signage.or.visible.documentation.of.environmental.work.or.actions., -If.so..what.kind.of.environmental.work., -Is.there.signage.or.visible.documentation.of.social.justice.work.or.actions., -If.so..what.kind.of.social.justice.work., -General.Notes, -address) %>%
  mutate(bread_quartile = cut(primary_table$Median.Price.of.a.Loaf.of.Bread, quantile(primary_table$Median.Price.of.a.Loaf.of.Bread, na.rm = TRUE),include.lowest=TRUE,labels=FALSE)) %>%
  mutate(milk_quartile = cut(primary_table$Milk.Standardized_Gallon, quantile(primary_table$Milk.Standardized_Gallon, na.rm = TRUE),include.lowest=TRUE,labels=FALSE)) %>%
  mutate(orange_quartile = cut(primary_table$Orange.Standardized_lbs, quantile(primary_table$Orange.Standardized_lbs, na.rm = TRUE),include.lowest=TRUE,labels=FALSE)) %>%
  mutate(avocado_quartile = cut(primary_table$Standardized.Avocado_each, quantile(primary_table$Standardized.Avocado_each, na.rm = TRUE),include.lowest=TRUE,labels=FALSE)) %>%
  mutate(carrots_quartile = cut(primary_table$Standardized.Carrots_lbs, quantile(primary_table$Standardized.Carrots_lbs, na.rm = TRUE),include.lowest=TRUE,labels=FALSE)) %>%
  mutate(brocolli_quartile = cut(primary_table$Standardized.Brocolli_lbs, quantile(primary_table$Standardized.Brocolli_lbs, na.rm = TRUE),include.lowest=TRUE,labels=FALSE)) %>%
  st_drop_geometry()
price_table$mean_quartile <- rowMeans(price_table[ , c("egg_quartile", "milk_quartile", "orange_quartile", "avocado_quartile", "carrots_quartile", "brocolli_quartile")], na.rm=TRUE)

price_map <- price_table %>%
  mutate(price_quartile = cut(price_table$mean_quartile, quantile(price_table$mean_quartile, na.rm = TRUE),include.lowest=TRUE,labels=FALSE))
price_map
primary_table_price <- left_join(primary_table, price_map, by = "Timestamp")
primary_table_price

Maps

dots_price <- tm_shape(primary_table_price) + tm_dots(size=.1, col="price_quartile", palette="Set1", showNA = FALSE)
incomemap_with_food_retailers <- tm_shape(incomejoin_test) +
             tm_style("watercolor") +
             tm_polygons("median_income") +
             tm_layout(main.title="Median Household Income & Food Retailers",
                       main.title.position = "centre",
                       main.title.size = 1.6) +
             tm_legend(position = c("right", "top"),
             legend.outside = TRUE,
             legend.outside.size = .35,
             legend.title.size = 1.5,
             legend.text.size = 1.2) +
  tm_compass(position = c("left", "top"))
income_plus_price <- incomemap_with_food_retailers + dots_price
ethnicity_plus_price <- ethnicity_map_with_food_retailers + dots_price
income_plus_price

ethnicity_plus_price

#### Tables

income_price_count <- primary_table_price %>% 
  rename("median_income" = "median_income.x") %>%
  group_by(median_income, price_quartile) %>% 
  count() %>%
  mutate(percent = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n")
income_price_print <- income_price_count[, c(1, 2, 3, 5, 4)]

ethnicity_price_count <- primary_table_price %>%
  rename("majority_ethnicity" = "Majority.x") %>%
  group_by(majority_ethnicity, price_quartile) %>%
  count() %>%
  mutate(percent = (n / nrow(primary_table)) * 100) %>%
  rename("number of retailers" = "n")
ethnicity_price_print <- ethnicity_price_count[, c(1, 2, 3, 5, 4)]

quartile_counts <- primary_table_price %>%
  group_by(price_quartile) %>%
  count() %>%
  mutate(percent = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n")
quartile_counts
#Translated via excel, then brought back in:
price_table_percent_income <- read_csv("Income Price Table (percent).csv")
## Rows: 13 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): median_income
## dbl (3): price_quartile, number of retailers, percent of quartile
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
price_table_percent_ethnicity <- read_csv("Ethnicity Price Table (percent).csv")
## Rows: 8 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): majority_ethnicity
## dbl (3): price_quartile, number of retailers, percent of quartile
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
price_table_percent_income
price_table_percent_ethnicity

EBT

Maps

income_plus_ebt <- incomemap_with_food_retailers + dots_ebt
income_plus_ebt

ethnicity_plus_ebt <- ethnicity_map_with_food_retailers + dots_ebt
ethnicity_plus_ebt

#### Tables

ebt_count <- primary_table %>%
  group_by(EBT.Accepted.) %>%
  count() %>% 
  mutate(percent = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n")
ebt_count
income_ebt_count <- intersection_join %>% 
  group_by(median_income, EBT.Accepted.) %>% 
  count() %>%
  filter(EBT.Accepted. == "Yes") %>%
  mutate(percent_ebt = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n") %>%
  slice(match(costum_order, median_income)) %>%
  st_drop_geometry()
income_ebt_count
ethnicity_ebt_count <- intersection_2 %>%
  rename("majority_ethnicity" = "Majority") %>%
  group_by(majority_ethnicity, EBT.Accepted.) %>%
  count() %>%
  filter(EBT.Accepted. == "Yes") %>%
  mutate(percent_ebt = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n") %>%
  st_drop_geometry()
ethnicity_ebt_count

Health & Nutrition

Percentage of Store Produce

Maps

dots_health <- tm_shape(primary_table) + tm_dots(size=.1, col="What.percentage.of.the.store.is.produce.", palette="Set1")
incomemap_with_food_retailers <- tm_shape(incomejoin_test) +
             tm_style("watercolor") +
             tm_polygons("median_income") +
             tm_layout(main.title="Median Household Income & Food Retailers",
                       main.title.position = "centre",
                       main.title.size = 1.6) +
             tm_legend(position = c("right", "top"),
             legend.outside = TRUE,
             legend.outside.size = .35,
             legend.title.size = 1.5,
             legend.text.size = 1.2) +
  tm_compass(position = c("left", "top"))
income_plus_health <- incomemap_with_food_retailers + dots_health
ethnicity_plus_health <- ethnicity_map_with_food_retailers + dots_health
income_plus_health

ethnicity_plus_health

#### Tables

income_health_count <- intersection_join %>% 
  group_by(median_income, What.percentage.of.the.store.is.produce.) %>% 
  count() %>%
  mutate(percent = (n / nrow(primary_table)) * 100) %>%
  rename("number of retailers" = "n")
income_health_count_crv <- income_health_count[, c(1, 2, 3, 5, 4)]

ethnicity_health_count <- intersection_2 %>%
  rename("majority_ethnicity" = "Majority") %>%
  group_by(majority_ethnicity, What.percentage.of.the.store.is.produce.) %>%
  count() %>%
  mutate(percent = (n / nrow(primary_table)) * 100) %>%
  rename("number of retailers" = "n")
ethnicity_health_count_crv <- ethnicity_health_count[, c(1, 2, 3, 5, 4)]
#write.csv(income_health_count_crv, "income health per produce.csv")
#write.csv(ethnicity_health_count_crv, "ethnicity health per produce.csv")
per_produce_income <- read_csv("income health per produce (percent).csv") %>% select(-percent)
## Rows: 16 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): median_income, What.percentage.of.the.store.is.produce.
## dbl (3): number of retailers, percent, percent_of_percent_produce
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
per_produce_ethnicity <- read_csv("ethnicity health per produce (percent).csv") %>% select(-percent)
## Rows: 9 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): majority_ethnicity, What.percentage.of.the.store.is.produce.
## dbl (3): number of retailers, percent, percent_of_percent_produce
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
per_produce_income
per_produce_ethnicity
perc_produce_counts <- primary_table_price %>%
  group_by(What.percentage.of.the.store.is.produce.) %>%
  count() %>%
  mutate(percent = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n")
perc_produce_counts

Fresh Produce

Maps

dots_produce <- tm_shape(primary_table) + tm_dots(size=.1, col="Is.there.fresh.produce.available.", palette="Set1")
incomemap_with_food_retailers <- tm_shape(incomejoin_test) +
             tm_style("watercolor") +
             tm_polygons("median_income") +
             tm_layout(main.title="Median Household Income & Food Retailers",
                       main.title.position = "centre",
                       main.title.size = 1.6) +
             tm_legend(position = c("right", "top"),
             legend.outside = TRUE,
             legend.outside.size = .35,
             legend.title.size = 1.5,
             legend.text.size = 1.2) +
  tm_compass(position = c("left", "top"))
income_plus_produce <- incomemap_with_food_retailers + dots_produce
ethnicity_plus_produce <- ethnicity_map_with_food_retailers + dots_produce
income_plus_produce

ethnicity_plus_produce

#### Tables

carry_produce_counts <- primary_table_price %>%
  group_by(Is.there.fresh.produce.available.) %>%
  count() %>%
  mutate(percent = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n")
carry_produce_counts
work_table <- intersection_join %>% 
  group_by(median_income) %>% 
  count()
income_produce_count <- intersection_join %>% 
  group_by(median_income, Is.there.fresh.produce.available.) %>% 
  count() %>%
  filter(Is.there.fresh.produce.available. == "Yes") %>%
  mutate(percent_produce = (n / sum(n)) * 100) %>%
  mutate(percent_produce_in_tract = (n / work_table$n * 100)) %>%
  rename("number of retailers" = "n") %>%
  slice(match(costum_order, median_income)) %>%
  st_drop_geometry()
income_produce_count
ethnicity_produce_count <- intersection_2 %>%
  rename("majority_ethnicity" = "Majority") %>%
  group_by(majority_ethnicity, Is.there.fresh.produce.available.) %>%
  count() %>%
  filter(Is.there.fresh.produce.available. == "Yes") %>%
  mutate(percent_produce = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n") %>%
  st_drop_geometry()
ethnicity_produce_count

Quantity of Produce

Maps

dots_quantity <- tm_shape(primary_table) + tm_dots(size=.1, col="How.many.types.of.fresh.produce.are.available.", palette="Set1")
incomemap_with_food_retailers <- tm_shape(incomejoin_test) +
             tm_style("watercolor") +
             tm_polygons("median_income") +
             tm_layout(main.title="Median Household Income & Food Retailers",
                       main.title.position = "centre",
                       main.title.size = 1.6) +
             tm_legend(position = c("right", "top"),
             legend.outside = TRUE,
             legend.outside.size = .35,
             legend.title.size = 1.5,
             legend.text.size = 1.2) +
  tm_compass(position = c("left", "top"))
income_plus_produce_quantity <- incomemap_with_food_retailers + dots_quantity
ethnicity_plus_produce_quantity <- ethnicity_map_with_food_retailers + dots_quantity
income_plus_produce_quantity

ethnicity_plus_produce_quantity

#### Tables

produce_quantity_w_bin <- intersection_join %>%
  mutate(produce_quantity_bins = case_when(
    How.many.types.of.fresh.produce.are.available. <= 10 ~ "0 to 10",
    How.many.types.of.fresh.produce.are.available. >= 11 & How.many.types.of.fresh.produce.are.available. <= 20 ~ "11 to 20",
    How.many.types.of.fresh.produce.are.available. >= 21 & How.many.types.of.fresh.produce.are.available. <= 30 ~ "21 to 30",
    How.many.types.of.fresh.produce.are.available. >= 31 & How.many.types.of.fresh.produce.are.available. <= 40 ~ "31 to 40",
    How.many.types.of.fresh.produce.are.available. >= 41 ~ "41 to 50+"))

produce_quantity_w_bin_2 <- intersection_2 %>%
  mutate(produce_quantity_bins = case_when(
    How.many.types.of.fresh.produce.are.available. <= 10 ~ "0 to 10",
    How.many.types.of.fresh.produce.are.available. >= 11 & How.many.types.of.fresh.produce.are.available. <= 20 ~ "11 to 20",
    How.many.types.of.fresh.produce.are.available. >= 21 & How.many.types.of.fresh.produce.are.available. <= 30 ~ "21 to 30",
    How.many.types.of.fresh.produce.are.available. >= 31 & How.many.types.of.fresh.produce.are.available. <= 40 ~ "31 to 40",
    How.many.types.of.fresh.produce.are.available. >= 41 ~ "41 to 50+"))

income_produce_quantity_count <- produce_quantity_w_bin %>% 
  group_by(median_income, produce_quantity_bins) %>% 
  count() %>%
  mutate(percent = (n / nrow(primary_table)) * 100) %>%
  rename("number of retailers" = "n")
produce_quantity_income <- income_produce_quantity_count[, c(1, 2, 3, 5, 4)]

ethnicity_produce_quantity_count <- produce_quantity_w_bin_2 %>%
  rename("majority_ethnicity" = "Majority") %>%
  group_by(majority_ethnicity, produce_quantity_bins) %>%
  count() %>%
  mutate(percent = (n / nrow(primary_table)) * 100) %>%
  rename("number of retailers" = "n")
produce_quantity_ethnicity <- ethnicity_produce_quantity_count[, c(1, 2, 3, 5, 4)]

quantity_produce_counts <- produce_quantity_w_bin %>%
  group_by(produce_quantity_bins) %>%
  count() %>%
  mutate(percent = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n")
quantity_produce_counts
#write.csv(produce_quantity_income, "produce_quantity_income.csv")
#write.csv(produce_quantity_ethnicity, "produce_quantity_ethnicity.csv")
per_produce_quantity_income <- read_csv("produce_quantity_income (percent).csv")
## Rows: 13 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): median_income, produce_quantity_bins
## dbl (2): number of retailers, percent_quantity
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
per_produce_quantity_ethnicity <- read_csv("produce_quantity_ethnicity (percent).csv")
## Rows: 9 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): majority_ethnicity, produce_quantity_bins
## dbl (2): number of retailers, percent_quantity
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
per_produce_quantity_income
per_produce_quantity_ethnicity

Cultural Relevance

Signage in Other Languages

Maps

dots_language <- tm_shape(primary_table) + tm_dots(size=.1, col="Is.there.signage.in.other.languages.than.English." , palette="Set1")
incomemap_with_food_retailers <- tm_shape(incomejoin_test) +
             tm_style("watercolor") +
             tm_polygons("median_income") +
             tm_layout(main.title="Median Household Income & Food Retailers",
                       main.title.position = "centre",
                       main.title.size = 1.6) +
             tm_legend(position = c("right", "top"),
             legend.outside = TRUE,
             legend.outside.size = .35,
             legend.title.size = 1.5,
             legend.text.size = 1.2) +
  tm_compass(position = c("left", "top"))
income_plus_language <- incomemap_with_food_retailers + dots_language
ethnicity_plus_language <- ethnicity_map_with_food_retailers + dots_language
income_plus_language

ethnicity_plus_language

#### Tables

other_language_counts <- primary_table %>%
  group_by(Is.there.signage.in.other.languages.than.English.) %>%
  count() %>%
  mutate(percent = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n")
other_language_counts
income_language_count <- intersection_join %>% 
  group_by(median_income, Is.there.signage.in.other.languages.than.English.) %>% 
  count() %>%
  filter(Is.there.signage.in.other.languages.than.English. == "Yes") %>%
  mutate(percent_with_other_language = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n") %>%
  slice(match(costum_order, median_income)) %>%
  st_drop_geometry()
income_language_count
ethnicity_language_count <- intersection_2 %>%
  rename("majority_ethnicity" = "Majority") %>%
  group_by(majority_ethnicity, Is.there.signage.in.other.languages.than.English.) %>%
  count() %>%
  filter(Is.there.signage.in.other.languages.than.English. == "Yes") %>%
  mutate(percent_with_other_language = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n") %>%
  st_drop_geometry()
ethnicity_language_count

Signage in Spanish

Maps

dots_other_languages <- tm_shape(primary_table) + tm_dots(size=.1, col="Is.there.signage.in.Spanish." , palette="Set1")
incomemap_with_food_retailers <- tm_shape(incomejoin_test) +
             tm_style("watercolor") +
             tm_polygons("median_income") +
             tm_layout(main.title="Median Household Income & Food Retailers",
                       main.title.position = "centre",
                       main.title.size = 1.6) +
             tm_legend(position = c("right", "top"),
             legend.outside = TRUE,
             legend.outside.size = .35,
             legend.title.size = 1.5,
             legend.text.size = 1.2) +
  tm_compass(position = c("left", "top"))
income_plus_languages <- incomemap_with_food_retailers + dots_other_languages
ethnicity_plus_languages <- ethnicity_map_with_food_retailers + dots_other_languages
income_plus_languages

ethnicity_plus_languages

#### Tables

other_language_counts <- primary_table %>%
  group_by(Is.there.signage.in.Spanish.) %>%
  count() %>%
  mutate(percent = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n")
other_language_counts
income_other_language_count <- intersection_join %>% 
  group_by(median_income, Is.there.signage.in.Spanish.) %>% 
  count() %>%
  filter(Is.there.signage.in.Spanish. == "Yes") %>%
  mutate(percent_with_spanish_signage = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n") %>%
  slice(match(costum_order, median_income)) %>%
  st_drop_geometry()
income_other_language_count
ethnicity_other_language_count <- intersection_2 %>%
  rename("majority_ethnicity" = "Majority") %>%
  group_by(majority_ethnicity, Is.there.signage.in.Spanish.) %>%
  count() %>%
  filter(Is.there.signage.in.Spanish. == "Yes") %>%
  mutate(percent_with_spanish_signage = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n") %>%
  st_drop_geometry()
ethnicity_other_language_count

LatinX Ethnic Food Section

Maps

dots_ethnic_section <- tm_shape(primary_table) + tm_dots(size=.1, col="Is.there.a.Hispanic.Latinx.ethnic.foods.section." , palette="Set1")
incomemap_with_food_retailers <- tm_shape(incomejoin_test) +
             tm_style("watercolor") +
             tm_polygons("median_income") +
             tm_layout(main.title="Median Household Income & Food Retailers",
                       main.title.position = "centre",
                       main.title.size = 1.6) +
             tm_legend(position = c("right", "top"),
             legend.outside = TRUE,
             legend.outside.size = .35,
             legend.title.size = 1.5,
             legend.text.size = 1.2) +
  tm_compass(position = c("left", "top"))
income_plus_ethnic <- incomemap_with_food_retailers + dots_ethnic_section
ethnicity_plus_ethnic <- ethnicity_map_with_food_retailers + dots_ethnic_section
income_plus_ethnic

ethnicity_plus_ethnic

#### Tables

costum_order_2 <- c("40,000 - 75,000", "75,001 - 110,000", "110,001 - 145,000")

ethnic_section_count <- primary_table %>%
  group_by(Is.there.a.Hispanic.Latinx.ethnic.foods.section.) %>%
  count() %>%
  mutate(percent = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n")
ethnic_section_count
ethnic_section_count_non_nat <- primary_table %>%
  group_by(Is.there.a.Hispanic.Latinx.ethnic.foods.section., Are.there.options.besides.national.name.brand.ethnic.foods.) %>%
  count() %>%
  filter(Is.there.a.Hispanic.Latinx.ethnic.foods.section. == "Yes") %>%
  mutate(percent = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n")
ethnic_section_count_non_nat
income_ethnic_section_count <- intersection_join %>% 
  group_by(median_income, Is.there.a.Hispanic.Latinx.ethnic.foods.section.) %>% 
  count() %>%
  filter(Is.there.a.Hispanic.Latinx.ethnic.foods.section. == "Yes") %>%
  mutate(perc_with_LatinX_ethnic_section = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n") %>%
  slice(match(costum_order_2, median_income)) %>%
  st_drop_geometry()
income_ethnic_section_count
income_ethnic_section_count_non_nat <- intersection_join %>% 
  group_by(median_income, Is.there.a.Hispanic.Latinx.ethnic.foods.section., Are.there.options.besides.national.name.brand.ethnic.foods.) %>% 
  count() %>%
  filter(Is.there.a.Hispanic.Latinx.ethnic.foods.section. == "Yes") %>%
  filter(Are.there.options.besides.national.name.brand.ethnic.foods. == "Yes") %>%
  mutate(perc_with_LatinX_non_national_ethnic_sections = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n") %>%
  slice(match(costum_order_2, median_income)) %>%
  st_drop_geometry()
income_ethnic_section_count_non_nat
ethnicity_ethnic_section_count <- intersection_2 %>%
  rename("majority_ethnicity" = "Majority") %>%
  group_by(majority_ethnicity, Is.there.a.Hispanic.Latinx.ethnic.foods.section.) %>%
  count() %>%
  filter(Is.there.a.Hispanic.Latinx.ethnic.foods.section. == "Yes") %>%
  mutate(perc_with_LatinX_ethnic_section = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n") %>%
  st_drop_geometry()
ethnicity_ethnic_section_count
ethnicity_ethnic_section_count_non_nat <- intersection_2 %>%
  rename("majority_ethnicity" = "Majority") %>%
  group_by(majority_ethnicity, Is.there.a.Hispanic.Latinx.ethnic.foods.section., Are.there.options.besides.national.name.brand.ethnic.foods.) %>%
  count() %>%
  filter(Is.there.a.Hispanic.Latinx.ethnic.foods.section. == "Yes") %>%
  filter(Are.there.options.besides.national.name.brand.ethnic.foods. == "Yes") %>%
  mutate(perc_with_LatinX_non_national_ethnic_sections = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n") %>%
  st_drop_geometry()
ethnicity_ethnic_section_count_non_nat

Sustainability

Environmental Sustainability

Maps

dots_environment <- tm_shape(primary_table) + tm_dots(size=.1, col="Is.there.signage.or.visible.documentation.of.environmental.work.or.actions." , palette="Set1")
incomemap_with_food_retailers <- tm_shape(incomejoin_test) +
             tm_style("watercolor") +
             tm_polygons("median_income") +
             tm_layout(main.title="Median Household Income & Food Retailers",
                       main.title.position = "centre",
                       main.title.size = 1.6) +
             tm_legend(position = c("right", "top"),
             legend.outside = TRUE,
             legend.outside.size = .35,
             legend.title.size = 1.5,
             legend.text.size = 1.2) +
  tm_compass(position = c("left", "top"))
income_plus_env <- incomemap_with_food_retailers + dots_environment
ethnicity_plus_env <- ethnicity_map_with_food_retailers + dots_environment
income_plus_env

ethnicity_plus_env

####Tables

env_signage_count <- primary_table %>%
  group_by(Is.there.signage.or.visible.documentation.of.environmental.work.or.actions.) %>%
  count() %>%
  mutate(percent = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n")
env_signage_count
income_env_count <- intersection_join %>% 
  group_by(median_income, Is.there.signage.or.visible.documentation.of.environmental.work.or.actions.) %>% 
  count() %>%
  filter(Is.there.signage.or.visible.documentation.of.environmental.work.or.actions. == "Yes") %>%
  mutate(perc_with_env_signage = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n") %>%
  slice(match(costum_order, median_income)) %>%
  st_drop_geometry()
income_env_count
ethnicity_env_count <- intersection_2 %>%
  rename("majority_ethnicity" = "Majority") %>%
  group_by(majority_ethnicity, Is.there.signage.or.visible.documentation.of.environmental.work.or.actions.) %>%
  count() %>%
  filter(Is.there.signage.or.visible.documentation.of.environmental.work.or.actions. == "Yes") %>%
  mutate(perc_with_env_signage = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n") %>%
  st_drop_geometry()
ethnicity_env_count

Social Sustainability

Maps

dots_social <- tm_shape(primary_table) + tm_dots(size=.1, col="Is.there.signage.or.visible.documentation.of.social.justice.work.or.actions." , palette="Set1")
incomemap_with_food_retailers <- tm_shape(incomejoin_test) +
             tm_style("watercolor") +
             tm_polygons("median_income") +
             tm_layout(main.title="Income and Social Sustainability",
                       main.title.position = "centre",
                       main.title.size = 1.6) +
             tm_legend(position = c("right", "top"),
             legend.outside = TRUE,
             legend.outside.size = .35,
             legend.title.size = 1.5,
             legend.text.size = 1.2) +
  tm_compass(position = c("left", "top"))
income_plus_social <- incomemap_with_food_retailers + dots_social
ethnicity_plus_social <- ethnicity_map_with_food_retailers + dots_social +
  tm_layout(main.title = "Ethnicity and Social Sustainability",
            main.title.position = "centre",
            main.title.size = 1.6)
income_plus_social

ethnicity_plus_social

#### Tables

soc_signage_count <- primary_table %>%
  group_by(Is.there.signage.or.visible.documentation.of.social.justice.work.or.actions.) %>%
  count() %>%
  mutate(percent = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n")
soc_signage_count
income_social_count <- intersection_join %>% 
  group_by(median_income, Is.there.signage.or.visible.documentation.of.social.justice.work.or.actions.) %>% 
  count() %>%
  filter(Is.there.signage.or.visible.documentation.of.social.justice.work.or.actions. == "Yes") %>%
  mutate(perc_with_social_signage = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n") %>%
  rename("Social Sustainability?" = "Is.there.signage.or.visible.documentation.of.social.justice.work.or.actions.") %>%
  slice(match(costum_order, median_income)) %>%
  st_drop_geometry()
income_social_count
ethnicity_social_count <- intersection_2 %>%
  rename("majority_ethnicity" = "Majority") %>%
  group_by(majority_ethnicity, Is.there.signage.or.visible.documentation.of.social.justice.work.or.actions.) %>%
  count() %>% 
  filter(Is.there.signage.or.visible.documentation.of.social.justice.work.or.actions. == "Yes") %>%
  mutate(perc_with_social_signage = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n") %>%
  rename("Social Sustainability?" = "Is.there.signage.or.visible.documentation.of.social.justice.work.or.actions.") %>%
  st_drop_geometry()
ethnicity_social_count

###Organic ####Maps

dots_organic <- tm_shape(primary_table) + tm_dots(size=.1, col="Is.there.organic.produce.available." , palette="Set1")
incomemap_with_food_retailers <- tm_shape(incomejoin_test) +
             tm_style("watercolor") +
             tm_polygons("median_income") +
             tm_layout(main.title="Income and Organic",
                       main.title.position = "centre",
                       main.title.size = 1.6) +
             tm_legend(position = c("right", "top"),
             legend.outside = TRUE,
             legend.outside.size = .35,
             legend.title.size = 1.5,
             legend.text.size = 1.2) +
  tm_compass(position = c("left", "top"))
income_plus_organic <- incomemap_with_food_retailers + dots_organic
ethnicity_plus_organic <- ethnicity_map_with_food_retailers + dots_organic +
  tm_layout(main.title = "Ethnicity and Organic",
            main.title.position = "centre",
            main.title.size = 1.6)
income_plus_organic

ethnicity_plus_organic

####Tables

costum_order_3 <- c("75,001 - 110,000", "110,001 - 145,000", "145,001 - 180,000")

organic_count <- primary_table %>%
  group_by(Is.there.organic.produce.available.) %>%
  count() %>%
  mutate(percent = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n")
organic_count
local_count <- primary_table %>%
  group_by(Is.there.local.produce.available.) %>%
  count() %>%
  mutate(percent = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n")
local_count
income_organic_count <- intersection_join %>% 
  group_by(median_income, Is.there.organic.produce.available.) %>% 
  count() %>%
  filter(Is.there.organic.produce.available. == "Yes") %>%
  mutate(perc_with_organic = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n") %>%
  slice(match(costum_order_3, median_income)) %>%
  st_drop_geometry()
income_organic_count
ethnicity_organic_count <- intersection_2 %>%
  rename("majority_ethnicity" = "Majority") %>%
  group_by(majority_ethnicity, Is.there.organic.produce.available.) %>%
  count() %>% 
  filter(Is.there.organic.produce.available. == "Yes") %>%
  mutate(perc_with_organic_produce_available = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n") %>%
  st_drop_geometry()
ethnicity_organic_count

###Local ####Maps

dots_local <- tm_shape(primary_table) + tm_dots(size=.1, col="Is.there.local.produce.available." , palette="Set1")
incomemap_with_food_retailers <- tm_shape(incomejoin_test) +
             tm_style("watercolor") +
             tm_polygons("median_income") +
             tm_layout(main.title="Income and Local",
                       main.title.position = "centre",
                       main.title.size = 1.6) +
             tm_legend(position = c("right", "top"),
             legend.outside = TRUE,
             legend.outside.size = .35,
             legend.title.size = 1.5,
             legend.text.size = 1.2) +
  tm_compass(position = c("left", "top"))
income_plus_local <- incomemap_with_food_retailers + dots_local
ethnicity_plus_local <- ethnicity_map_with_food_retailers + dots_local +
  tm_layout(main.title = "Ethnicity and Local",
            main.title.position = "centre",
            main.title.size = 1.6)
income_plus_local

ethnicity_plus_local

####Tables

costum_order_3 <- c("75,001 - 110,000", "110,001 - 145,000", "145,001 - 180,000")

local_count <- primary_table %>%
  group_by(Is.there.local.produce.available.) %>%
  count() %>%
  mutate(percent = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n")
local_count
income_local_count <- intersection_join %>% 
  group_by(median_income, Is.there.local.produce.available.) %>% 
  count() %>%
  filter(Is.there.local.produce.available. == "Yes") %>%
  mutate(perc_with_local_produce = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n") %>%
  slice(match(costum_order_3, median_income)) %>%
  st_drop_geometry()
income_local_count
ethnicity_local_count <- intersection_2 %>%
  rename("majority_ethnicity" = "Majority") %>%
  group_by(majority_ethnicity, Is.there.local.produce.available.) %>%
  count() %>% 
  filter(Is.there.local.produce.available. == "Yes") %>%
  mutate(perc_with_local_produce = (n / sum(n)) * 100) %>%
  rename("number of retailers" = "n") %>%
  st_drop_geometry()
ethnicity_local_count